<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">


      <el-button plain   @click="abc(0)">待入职{{statisticsNum.count0}}人</el-button>&nbsp;&nbsp;&nbsp;
      <el-button plain  @click="abc(1)" >已入职{{statisticsNum.count1}}人</el-button>&nbsp;&nbsp;&nbsp;
     <!-- <el-button plain  @click="abc(2)" >RPO{{statisticsNum.count3}}人</el-button>&nbsp;&nbsp;&nbsp;-->
      <el-button type="primary" @click="abc(3)" >放弃入职{{statisticsNum.count2}}人</el-button>&nbsp;&nbsp;&nbsp;
      <el-form-item  prop="all">
        <el-input
          v-model="queryParams.all"
          placeholder="请输入简历名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!--淘汰弹出框 -->
<!--    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      >
      <span>淘汰原因：</span>
      <template>
        <el-select v-model="soeliminate" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </template>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="handleDeletes()">确 定</el-button>
  </span>
    </el-dialog>-->

    <el-table v-loading="loading" :data="managmentlist"
              style="width: 100%" max-height="100%">
<!--      <el-table-column label="主键" align="center" prop="id" />-->
      <el-table-column label="姓名" align="center" prop="name"  width="100" />
      <el-table-column label="电话" align="center" prop="phone"  width="180"  />
      <el-table-column label="应聘职位" align="center" prop="positionApplied"  width="180"  />
      <el-table-column label="职位类型" align="center" prop="positionType"  width="180" />
     <!-- <el-table-column label="企业" align="center" prop="enterprise"  width="100" />-->
<!--
<el-table-column label="项目组" :show-overflow-tooltip="true" align="center" prop="proName" width="100"/>
-->
      <el-table-column label="创建人" align="center" prop="uname" width="100"/>
      <el-table-column label="原定到岗日期" align="center" prop="expectedDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="放弃入职原因" align="center" prop="soeliminate"  width="100" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="200" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row.id)"
            v-hasPermi="['system:auitvo:edit']"
          >转移到待入职</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="deleteId(scope.row.id)"
            v-hasPermi="['system:auitvo:edit']"
          >删除</el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
import {list, statisticsNum, updateStatus,deleteId} from "@/api/system/Management";


export default {
  name: "Auitvo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      id:null,
      resumeId:null,
      isFirst:null,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      /*淘汰原因*/
      soeliminate:null,
      /*淘汰阶段*/
      ofeliminate:null,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      managmentlist: [],
      statisticsNum:{
        count0:0,
        count1:0,
        count2:0,
        count3:0,
        count4:0
      },
      dialogVisible: false,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      options: [{
        value: '',
        label: '请选择'
      },{
        value: '个人原因',
        label: '个人原因'
      }, {
        value: '接收其他offer',
        label: '接收其他offer'
      }, {
        value: '薪资不满意',
        label: '薪资不满意'
      }, {
        value: '职位不满意',
        label: '职位不满意'
      }, {
        value: '工作地点不满意',
        label: '工作地点不满意'
      }, {
        value: '其他',
        label: '其他'
      }],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        status:5,
        all:null,
        positionType:null,
        name: null,
        gender: null,
        age: null,
        dateOfBirth: null,
        isMarriage: null,
        isBirth: null,
        ethnicGroup: null,
        politicalOutlook: null,
        documentType: null,
        identificationNumber: null,
        registeredResidence: null,
        phone: null,
        mailbox: null,
        currentAddress: null,
        emergencyContact: null,
        emergencyContactNumber: null,
        schoolName: null,
        education: null,
        major: null,
        isDelete: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      resumeIds:[]

    };
  },
  created() {
    this.getList();
    this.statistics();
  },
  methods: {
    abc(s) {
      var path = null;
      if (s == 0){
        path = 'beemployed'
      }
      if (s == 1){
        path = 'employeds'
      }
      if (s == 2){
        path = 'rpopost'
      }
      if (s == 3){
        path = 'Abemployment'
      }

      this.$router.push({ path:'/employeefiles/Management/'+ path}  ).catch(()=>{})
    },
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      list(this.queryParams).then(response => {
        this.managmentlist = response.rows;
        this.total = response.total;
      });
      this.loading = false;
    },
    /** 统计数量 */
    statistics() {
      statisticsNum().then(response => {
        if (response.data !== undefined){
          this.statisticsNum = response.data;
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        status:5,
        positionType:'RPO',
        gender: null,
        age: null,
        dateOfBirth: null,
        isMarriage: null,
        isBirth: null,
        ethnicGroup: null,
        politicalOutlook: null,
        documentType: null,
        identificationNumber: null,
        registeredResidence: null,
        phone: null,
        mailbox: null,
        currentAddress: null,
        emergencyContact: null,
        emergencyContactNumber: null,
        schoolName: null,
        education: null,
        major: null,
        isDelete: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams={
        pageNum: 1,
        pageSize: 10,
        status:5,
        all:null,
        positionType:null,
        name: null,
        gender: null,
        age: null,
        dateOfBirth: null,
        isMarriage: null,
        isBirth: null,
        ethnicGroup: null,
        politicalOutlook: null,
        documentType: null,
        identificationNumber: null,
        registeredResidence: null,
        phone: null,
        mailbox: null,
        currentAddress: null,
        emergencyContact: null,
        emergencyContactNumber: null,
        schoolName: null,
        education: null,
        major: null,
        isDelete: null,
      },
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 转移到待入职**/
    handleUpdate(id){
      this.$modal.confirm('是否转移到待入职').then(function() {
        return updateStatus(id);
      }).then(() => {
        this.$modal.msgSuccess("操作成功");
        this.getList();
        this.statistics();
      }).catch(() => {});

    },
    /** 删除**/
    deleteId(id){
      var isDelete = 1;
      this.$modal.confirm('是否删除').then(function() {
        return deleteId(id,isDelete);
      }).then(() => {
        this.$modal.msgSuccess("操作成功");
        this.getList();
        this.statistics();
      }).catch(() => {});

    }



  }
};
</script>
